<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!--返回错误信息-->
<?php echo validation_errors(); ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <?php
    $title = [
        'title' => '需求单详情',
    ];
    $this->load->view('/admin/common/header', $title);
    ?>
</head>

<body data-type="widgets">
<script src="/assets/js/theme.js"></script>
<div class="am-g tpl-g">

    <?php
//        print_r($list);
//        die();
    ?>

    <!--    头部   侧边菜单-->
    <?php $this->load->view('/admin/common/bodyLeft'); ?>
    <script type="text/javascript">
    	$(".js-sidebar-nav>li:nth-child(10)>ul").show(80);
    	$(".js-sidebar-nav>li:nth-child(10)>a>span").addClass("sidebar-nav-sub-ico-rotate");
    	$(".js-sidebar-nav>li:nth-child(10)>ul>li:nth-child(3)>a").addClass("active");
    </script>
    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">
                                <ol class="am-breadcrumb am-breadcrumb-slash">
                                    <li><a href="/admin/stock/put/index?page=1">库存管理</a></li>
                                    <li><a href="/admin/stock/put?page=1">商品入库</a></li>
                                    <li class="am-active">入库单详情</li>
                                </ol>
                            </div>
                        </div>
                        <form action="/admin/stock/confirm" method="post" enctype="multipart/form-data" class="am-form am-text-sm">
                        <div class="widget-body  am-fr">
                            <div class="tpl-table-black-operation">
                                <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                    基本信息
                                </a>
                            </div>

                            <div style="margin-top: 20px">
                                <div class="am-u-sm-12">
                                    <!-- Row start -->
                                    <div class="am-g">

                                        <div class="am-u-sm-6">
                                            <div class="am-form-group am-u-sm-12">
                                                    <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                           for="">单编号</label>
                                                   <div class="am-u-md-10">
                                                        <input type="text" id="" name='stockPutCode' value="<?php echo $list['stockPutCode'] ?>" disabled="disabled">
                                                   </div>
                                                    
                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">供货方</label>
                                                <div class="am-u-md-10">
                                                    <input type="text" id="" name='supplier' value="<?php echo $list['supplier'] ?>" disabled="disabled">
                                                </div>

                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0" for="">关联单据</label>
                                                <div class="am-u-md-10">
                                                    <input type="text" id="" name='danju' value="进货单" disabled="disabled">
                                                </div>
                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">制单人</label>
                                                <div class="am-u-md-10"> 
                                                    <input type="text" id="" name='createMan' value="<?php echo $list['createMan']?>" disabled="disabled">
                                                </div>
                                               
                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                    <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                           for="doc-ta-1">申请原因</label>
                                                    <div class="am-u-md-10">
                                                        <textarea rows="5" id="doc-ta-1" disabled="disabled"><?php echo $list['content'] ?></textarea>
                                                    </div>
                                            </div>
                                        </div>
                                        <div class="am-u-sm-6">

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0 must"
                                                       for="name">入库单名称：</label>
                                                <div class="am-u-md-10">
                                                    <input  type="text"  name="name" value="<?php echo $list['name'] ?>" disabled="disabled"
                                                            id="name">
                                                </div>
                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">单据时间</label>
                                                <div class="am-u-md-10">
                                                    <input type="text" id="" name='time' value="<?php echo date('Y-m-d')?>" disabled="disabled">
                                                </div>
                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">收货方</label>
                                                <div class="am-u-md-10">
                                                    <input type="text" id="" name='shouhuo' value="浙江爱思特科技发展有限公司" disabled="disabled">
                                                </div>
                                            </div>

                                            <div class="am-form-group am-u-sm-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">关联单号</label>
                                                <div class="am-u-md-10">
                                                    <input class="am-u-md-10 form-control" type="text" 
                                                           id="" name='purchaseCode' value="<?php echo $list['purchaseCode']?>" disabled="disabled">
                                                 </div>
                                            </div>


                                            <div class="am-form-group am-u-md-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">所属项目</label>
                                                <div class="am-u-md-10">
                                                    <input type="text" id="" name='source' value="<?php echo $list['source']?>" readonly>
                                                </div>
                                            </div>
                                    </div>

                                </div>
                                    <!-- Row end -->
                                </div>
                                <hr>
                            </div>

                            <div class="tpl-table-black-operation">
                                <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                    详细信息
                                </a>
                            </div>

                            <div style="margin-top: 20px">
                                <div class="am-u-sm-12">
                                    <table class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                        <thead>
                                        <tr>
                                            <th width="5%">序号</th>
                                            <th width="15%">商品编码</th>
                                            <th width="10%">商品名称</th>
                                            <th width="15%">商品规格</th>
                                            <th width="5%">单位</th>
                                            <th width="10%">进货数量</th>
                                            <th width="10%">进货单价</th>
                                            <th width="10%">进货金额</th>
                                            <th width="20%">备注</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <?php

                                        foreach ($list['goodsMessage'] as $k=>$v){
                                            echo '<tr class="line">
                                              
                                                   <td class="order">'.$v['order'].'</td>
                                                <td data-id="'.$v['dataId'].'" class="product_no">'.$v['product_no'].'</td>
                                                <td class="name">'.$v['name'].'</td>
                                                <td class="specification"   >'.$v['specification'].'</td>
                                                <td class="goodsUnit">'.$v['goodsUnit'].'</td>';

                                            if($v['isStock']){
                                                echo '<td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control quantity" value="'.$v['quantity'].'" disabled="disabled">
                                                    </div>
                                                </td>
                                                <td >
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control price" value="'.$v['price'].'" disabled="disabled">
                                                    </div>
                                                </td>
                                                <td class="price-all">'.$v['priceAll'].'</td>
                                                <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control remarks" value="'.$v['remarks'].'" disabled="disabled">
                                                    </div>
                                                </td>
                                            </tr>';
                                            }else{
                                                echo '          <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control quantity" value="'.$v['quantity'].'" disabled="disabled">
                                                    </div>
                                                </td>
                                                <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control price" value="'.$v['price'].'" disabled="disabled">
                                                    </div>
                                                </td>
                                                <td class="price-all">'.$v['priceAll'].'</td>

                                                <td>
                                                    <div class="am-form">
                                                        <input type="text" name="" class="am-u-md-12 form-control remarks" value="'.$v['remarks'].'" disabled="disabled">
                                                    </div>
                                                </td>
                                            </tr>';
                                            }

                                        }


                                        ?>
                                        <!-- more data -->
                                        </tbody>
                                    </table>
                                    <hr>
                                </div>
                            </div>

                            <?php
                                if($list['payInfo']){
                                    echo '<div class="tpl-table-black-operation">
                                 <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                     财务信息
                                 </a>
                            </div>
';
                                }
                            ?>

                            <div style="margin-top: 20px">
                                <!-- Row start -->
                                <div class="am-u-sm-12">
                                        <div class="am-u-md-6">
                                            <?php
                                            if($list['payInfo']){
                                                foreach ($list['payInfo'] as $k=>$v){
                                                    switch ($v['prepay']) {
                                                        case 0.05:
                                                            $v['prepay'] = '预付款5%';
                                                            break;
                                                        case 0.10:
                                                            $v['prepay'] = '预付款10%';
                                                            break;
                                                        case 0.15:
                                                            $v['prepay'] = '预付款15%';
                                                            break;
                                                        case 0.2:
                                                            $v['prepay'] = '预付款20%';
                                                            break;
                                                        case 0.3:
                                                            $v['prepay'] = '预付款30%';
                                                            break;
                                                        case 0.4:
                                                            $v['prepay'] = '预付款40%';
                                                            break;
                                                        case 0.5:
                                                            $v['prepay'] = '预付款50%';
                                                            break;
                                                        case 0.6:
                                                            $v['prepay'] = '预付款60%';
                                                            break;
                                                        case 0.7:
                                                            $v['prepay'] = '预付款70%';
                                                            break;
                                                        case 0.8:
                                                            $v['prepay'] = '预付款80%';
                                                            break;
                                                        case 1:
                                                            $v['prepay'] = '预付款100%';
                                                            break;
                                                    }

                                                    echo ' <div class="am-form-group am-u-sm-12">
                                                    <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                           for="">预付款</label>
                                                    <div class="am-u-md-10">

                                                    <input id="" type="text" value="'.@$v['prepay'].'" disabled="disabled">
                                            </div></div>';
                                                }
                                            }

                                            ?>
                                        </div>
                                        <div class="am-u-md-6">
                                                <?php
                                                if($list['payInfo'] && (count($list['payInfo']) == 1)){
                                                    echo '<div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                    <div class="am-u-md-10">
                                                        <input type="text"
                                                               id="" value="已确定付款"  disabled="disabled" >
                                                    </div>
                                                </div>';
                                                }else{
                                                    if($list['purStatus'] > 3){
                                                        echo '<div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                    <div class="am-u-md-10">
                                                        <input type="text"
                                                               id="" value="已确定付款"  disabled="disabled" >
                                                    </div>
                                                </div>
                                                <div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                        <div class="am-u-md-10">
                                                        <input type="text"
                                                               id="" value="已确定付款"  disabled="disabled">
                                                    </div>
                                                </div>
                                                <div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                        <div class="am-u-md-10">
                                                        <input type="text"
                                                               id="" value="已确定付款"  disabled="disabled">
                                                    </div>
                                                </div>';
                                                    }else{
                                                        echo ' <div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                        <div class="am-u-md-10">
                                                            <input type="text"
                                                               id="" value="已确定付款"  disabled="disabled">
                                                        </div>
                                                </div>
                                                <div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                        <div class="am-u-md-10">
                                                        <input type="text"
                                                               id="" value="已确定付款" disabled="disabled">
                                                        </div>
                                                </div>
                                                <div class="am-form-group am-u-sm-12">
                                                        <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                               for="">状态</label>
                                                        <div class="am-u-md-10">
                                                        <input type="text"
                                                               id="" value="未确定付款" disabled="disabled">
                                                        </div>
                                                </div>';
                                                    }
                                                }

                                                ?>
                                        </div>
                                </div>
                                <!-- Row end -->
                            </div>

                            <div class="tpl-table-black-operation">
                                <a href="javascript:void(0);" class="tpl-table-black-operation-del">
                                    物流信息
                                </a>
                            </div>

                            <div style="margin-top: 20px">
                                    <!-- Row start -->
                                    <div class="am-u-sm-12">
                                        <div class="am-u-md-6">
                                            <div class="am-form-group am-u-sm-12">
                                                    <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                           for="">物流公司</label>
                                                    <div class="am-u-md-10">
                                                    <?php
                                                        if($list['express']){
                                                            echo '<input type="text" value="'.$list['express'].'" id="" name="express" readonly>';

                                                        }else{
                                                            echo '<input type="text" id="" name="express">';
                                                        }
                                                    ?>
                                                    </div>
                                            </div>

                                        </div>

                                        <div class="am-u-md-6">
                                            <div class="am-form-group am-u-md-12">
                                                <label class="am-u-md-2 am-md-text-right am-padding-left-0"
                                                       for="">快递单号</label>
                                                <div class="am-u-md-10">
                                                <?php
                                                    if ($list['courierNumber']){
                                                        echo '<input  type="text" name="courierNumber" value="'.$list['courierNumber'].'" readonly/>';
                                                    }else{
                                                        echo '<input  type="text" name="courierNumber" />';
                                                    }
                                                ?>
                                                </div>
                                            </div>
                                        </div>

                                        <input type="hidden" name="type" value="put" />
                                        <input type="hidden" name="id" value="<?php echo $list['id'] ?>" />

                                    </div>
                                    <!-- Row end -->
                                <div class="btn-box">
                                    <?php

                                    if(!$list['status']){
                                        echo '<input type="submit" value="完成收货" class="am-btn am-btn-primary tpl-btn-bg-color-success " style="width:220px;margin: 20px;">
                                                <button onclick="back()" type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " style="width:220px">取消</button>';
                                    }else{
                                        echo '<button onclick="back()" type="button" class="am-btn am-btn-primary tpl-btn-bg-color-success " style="width:220px">取消</button>';
                                    }
                                    ?>
                                </div>

                            </div>
                        </div>
                    </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>
<script>
    function back() {
        window.history.back();
    }
</script>

<script src="/assets/js/amazeui.min.js"></script>
<script src="/assets/js/amazeui.datatables.min.js"></script>
<script src="/assets/js/dataTables.responsive.min.js"></script>
<script src="/assets/js/app.js"></script>
<script>
    var lockSubmit = false;
    $("[type='submit']").click(function(e) {
        if(lockSubmit){
            return false;
        }
        lockSubmit =true;

    });
</script>
</body>

</html>